package com.store.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.common.common.BaseResponse;
import com.common.common.ErrorCode;
import com.common.exception.MyBlockExceptionHandler;
import com.common.common.ResultUtils;
import com.common.controller.AbstractTypedController;
import com.store.entities.Store;
import com.store.service.StoreServiceImpl;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.concurrent.TimeUnit;

@Component
@RestController
@Slf4j
@CrossOrigin
@Tag(name = "菜单表")
@RequestMapping("store")
public class StoreController extends AbstractTypedController<Store, Integer> {
    private static final String RESOURCE_NAME = "store";


    @Resource
    StoreServiceImpl ssvc;

    StoreController( StoreServiceImpl storeService ) {
        this.svcContext = storeService;
        this.ssvc = storeService;
    }

    @GetMapping("/searchfoodsbybid/{bid}")
    @Operation(summary = "通过bid查询菜品")
    public BaseResponse<List<Store>> searchFoods( @PathVariable Integer bid ) throws InterruptedException {
        List<Store> businessList;
        try {
            businessList = ssvc.searchFoods(bid);
        } catch (Exception e) {
            return ResultUtils.error(ErrorCode.SYSTEM_ERROR, "服务器错误");
        }
        return ResultUtils.success(businessList);
    }

    //
//    @Value("${server.port}")
//    private String serverPort;
//
//    @RequestMapping("/port")
//    BaseResponse<String> GetPort() {
//        return ResultUtils.success(serverPort);
//    }

}
